package cn.itcast.search.service.impl;

import cn.itcast.hmall.dto.common.PageDTO;
import cn.itcast.hmall.dto.search.SearchReqDTO;
import cn.itcast.hmall.pojo.item.ItemDoc;
import cn.itcast.search.service.SearchService;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@Service
public class SearchServiceImpl implements SearchService {

    @Autowired
    private RestHighLevelClient restHighLevelClient;

    @Override
    public PageDTO<ItemDoc> search(SearchReqDTO searchReqDTO) throws IOException {
//
//        //创建对象
//        SearchRequest request = new SearchRequest("item");
//        request.source().trackTotalHits(true);  //获取超过1w条数据
//        // 调用方法，封装请求的DSL语句
//
//
//        //设置分页
//        request.source().from((searchReqDTO.getPage() - 1) * searchReqDTO.getSize());
//        request.source().size(searchReqDTO.getSize());
        return null;
    }

    @Override
    public Map<String, List<String>> filter(SearchReqDTO searchReqDTO) {
        return null;
    }

    @Override
    public List<String> getSuggestions(String prefix) {
        return null;
    }
}
